
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>分配角色</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/css/global.css" media="all">
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/plugins/layui/css/public.css" media="all" />

    <style>
        .layui-form-label {
            width: 10%;
        }
        .layui-input-block {
            margin-left: 12%;
        }
        img {
            width: 110px;
            height: 110px;
        }
        .layui-upload-list {
            margin-left: 12%;
        }
    </style>
</head>

<body>
<div style="margin: 15px;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>分配角色</legend>
        <div class="layui-input-block">
           <!--  <a href="javascript:history.back();" class="layui-btn" style="float: right;">返回</a> -->
        </div>
    </fieldset>
	<form class="layui-form" action="/manage/account/saveAccountRole">
	  <div class="layui-form-item">
	    <label class="layui-form-label">用户名</label>
	    <div class="layui-input-block">
	      <input type="text" name="name" id="name" maxlength="50" required disabled="disabled"  lay-verify="required" placeholder="请输入角色名称"  value="${account.userName!}" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  
	  <div class="layui-form-item">
	    <label class="layui-form-label">昵称</label>
	    <div class="layui-input-block">
	      <input type="text" name="nickName" id="nickName" maxlength="50" required disabled="disabled"  lay-verify="required" placeholder="请输入角色名称"  value="${account.nickName!}" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  
	  <div class="layui-form-item">
            <label class="layui-form-label">用户头像</label>
            <div class="layui-input-block">
                <img style="width: 110px;height: 110px;" src="${account.head}">
            </div>
        </div>
	  
	  <div class="layui-form-item">
					<label class="layui-form-label layui-required-tip">角色</label>
					<div class="layui-input-block">
						<select  multiple lay-search name="roleIds" id="roleIds" lay-verify="required">
							<option value="">请选择角色</option>
							<#list roleList as role>
							<#if role.isCheck==1>
									<option value="${role.id}" selected="selected">${role.name}</option>
									<#else>
									<option value="${role.id}">${role.name}</option>
									</#if>
							</#list>
						</select>
					</div>
				</div>
	  
	  <div class="layui-form-item">
	    <div class="layui-input-block">
	       <input type="hidden" name="accountId" value="${account.id}" id="accountId"/>
	      <button class="layui-btn" lay-submit="" lay-filter="formSubmit">立即提交</button>
	      <button type="button" class="layui-btn layui-btn-primary" onclick="javascript:history.back();">返回</button>
	    </div>
	  </div>
	</form>
	</div>


 <script type="text/javascript" src="/plugins/layui/layui.js"></script>
<script>
layui.config({
	  base: '/js/' //假设这是你存放拓展模块的根目录
	}).extend({ //设定模块别名
	  mymod: 'selectMultiple' //如果 mymod.js 是在根目录，也可以不用设定别名
	});
layui.use(['form','layer','selectMultiple'], function(){
  var upload = layui.upload
  ,form=layui.form
  ,layer = layui.layer //弹层
  ,selectMultiple=layui.selectMultiple
  ,$=layui.jquery;
 
  //监听提交
  
  $("#formSubmit").bind("click",function(){
	  alert($("#roleIds").val())
	  $.ajax({
          type : "POST",
          url : "/manage/account/saveAccountRole",
          dataType : "json",
          data :{"account":$("#acccountId").val()},
          success : function(data) {
        	  layer.alert(data.msg, {
        		    skin: 'layui-layer-molv' //样式类名  自定义样式
        		    ,closeBtn: 1    // 是否显示关闭按钮
        		    ,anim: 1 //动画类型
        		    ,btn: ['确定'] //按钮
        		    ,icon: data.code>=0?1:2    // icon
        		    ,yes:function(index){
        		    	if (data.code >= 0) {
        	                  location.href = "/manage/account/accountList";
        	              }else{
        	            	  layer.close(index);
        	              }
        		    }});
          },
          error : function() {
              alert("系统异常,请稍后重试");
          }
      });
    return false;
  }); 

});
</script>

</body>
</html>
      